#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QSettings>
#include <QCloseEvent>
#include "configurations.h"
#include "udpserverthread.h"
#include "serialportthread.h"
#include "udpparser.h"

QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();
    void closeEvent(QCloseEvent *event);

    QString *configPath;
    Configurations *basicConfig;
    static char* convertString(QString);
    UDPServerThread *udpCollector;
    SerialPortThread *serialCollector;

private slots:
    void loadConfig(QString&);

    // Btn slots
    void startMeasBtnAction();
    void stopMeasBtnAction();
    void on_startColBtn_clicked();


    // Action slots
    void actionUDPServerConfig();
    void actionSerialConfig();

    void switchCollector();

    void setEnabledForWidget();

    void onRecUDPData(udpInfo udpInfo);

private:
    Ui::MainWindow *ui;

    void initSlots();
    void updateBotLayout();

    bool isUdp = false, isSerial = false;
    int count = 0;
};

QString markTimer(QString str);
#endif // MAINWINDOW_H
